<!-- components/Account.vue -->
<template>
	<view class="account-warpper">
		<!-- 标题 -->
		<Navbar 
		title=" "
		></Navbar>
		<view class="list flex-between" v-for="(item,index) in list" :key="index">
			<view class="left u-flex-column">
				<text class="title">
					{{item.title}}
				</text>
				<text class="time">申请时间：{{item.updatetime}}</text>
			</view>
			<view class="right  u-flex-column">
				<text :class="item.status=='审核中'?'status':''">{{item.status}}</text>
				<view class="price-box">
					<text>+</text>
					<text class="price">{{item.withdraw_money}}</text>
				</view>
			</view>
			
			
		</view>
		<!-- 加载状态提示 -->
		<u-loadmore :status="loadStatus" :loading-text="loadingText" :loadmore-text="loadmoreText"
			:nomore-text="nomoreText" marginTop="72rpx" color="#999" lineColor="#D9DCE2" line lineWidth="99rpx" />
	</view>
</template>

<script setup>
	import {ref,reactive,computed,onMounted} from 'vue'
	import Navbar from '../../../components/Navbar.vue';
	import NotData from '../../../components/NotData.vue';
	
	// 列表数据
	const list = ref([])
	// 当前页码
	const currentPage = ref(1)
	// 是否正在加载
	const loading = ref(false)
	// 加载状态提示
	const loadingText = ref('努力加载中');
	const loadmoreText = ref('滑动加载更多');
	const nomoreText = ref('实在没有了');
	// 是否还有更多数据
	const hasMore = ref(true)
	// 滚动区域高度
	const scrollHeight = ref(0)
	// 加载状态
	const loadStatus = ref('loadmore')
	// 加载更多
	const loadMore = () => {
		if (!loading.value && hasMore.value) {
			currentPage.value++
			getListData(currentPage.value)
		}
	}
	// 初始化加载
	onMounted(() => {
		const pages = getCurrentPages()
		const currentPage = pages[pages.length - 1]
		const options = currentPage.options
		// 计算滚动高度（根据你的页面布局调整）
		scrollHeight.value = uni.getSystemInfoSync().windowHeight - 50
		getListData(1)
	})
	const getListData = (page=1)=>{
		uni.$api.user.withdrawLog({
			page
		}).then((res)=>{
			if (page === 1) list.value = []
			const data = ref(res.data.data.map((item, i) => ({
				updatetime: item.updatetime,
				status: item.status,
				title: item.title,
				withdraw_money: item.withdraw_money,
			})));
			list.value = [...list.value, ...data.value];
			
			hasMore.value = page < res.last_page;
			loadStatus.value = hasMore.value ? 'loadmore' : 'nomore'
		})
	}

</script>

<style lang="scss" scoped>
	.account-warpper{
		margin-top: 100rpx;
	}
.navbar{
	height: 140rpx;
}
.list{
	margin: 20rpx 30rpx;
	padding: 32rpx 10rpx;
	border-bottom: 1px solid #E7E7E7;
	color: #999999;
	font-size: 24rpx;
	.left{
		font-size: 28rpx;
		color: #222222;
		.title{
			margin-bottom: 12rpx;
		}
		.time{
			font-size: 24rpx;
			color: #999;
			margin-top: 25rpx;
		}
	}
	.right{
		font-size: 26rpx;
		
		.status{
			color: #F2B600;
		}
		.price-box{
			font-weight: bold;
			color: #FF413B;
			.price{
				margin-top: 12rpx;
				font-size: 32rpx;
			}
		}
	}
}
</style>